﻿using Microsoft.Practices.Prism.UnityExtensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Practices.Unity;
using System.Windows;
using Microsoft.Practices.Prism.Regions;
using Ezpay.UI.ViewModels;
using Ezpay.ServiceContract;
using AutoMapper;

namespace Ezpay.UI
{
    class Bootstrapper : UnityBootstrapper
    {
        protected override System.Windows.DependencyObject CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }
        protected override void InitializeShell()
        {
            base.InitializeShell();
            Application.Current.MainWindow = Shell as MainWindow;
            Application.Current.MainWindow.Show();
        }

        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            Container.RegisterType<IEzpayService, EzpayService>();
        }

        protected override void InitializeModules()
        {
            base.InitializeModules();

            var regionManager = Container.Resolve<IRegionManager>();

            Container.RegisterType<object, CustomerViewModel>("CustomerViewModel");
            Container.RegisterType<object, HousingAgencyViewModel>("HousingAgencyViewModel");
            Container.RegisterType<object, NewCustomerViewModel>("NewCustomerViewModel");
            Container.RegisterType<object, EditCustomerViewModel>("EditCustomerViewModel");

            Mapper.CreateMap<GetCustomerResponse, UpdateCustomerRequest>();
            Mapper.CreateMap<GetCustomerResponse, CustomerViewModel>();

            Mapper.CreateMap<Customer, GetCustomerResponse>();
            Mapper.CreateMap<CreateNewCustomerRequest, Customer>();
            Mapper.CreateMap<UpdateCustomerRequest, Customer>();
            

            regionManager.RegisterViewWithRegion("SearchRegion", typeof(SearchViewModel));
            regionManager.RegisterViewWithRegion("NavigationRegion", typeof(NavigationViewModel));
            regionManager.RegisterViewWithRegion("HistoryRegion", typeof(NavigationHistoryViewModel));
            
            
        }

        
    }
}
